package com.rogan.rea;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class BasicModel implements Runnable{

	@Override
	public void run() {
		try {
			ServerSocket ss = 
					new ServerSocket(8080);
			
			while (!Thread.interrupted())
				new Thread(new Handler(ss.accept())).start();
		} catch (IOException ex) {
		}
	}
	
	static class Handler implements Runnable {
		final Socket socket;
		Handler(Socket s){socket = s;}
		@Override
		public void run() {
			try {
				byte[] input = new byte[1024];
				socket.getInputStream().read(input);
				byte[] output = process(input);
				socket.getOutputStream().write(output);
			} catch (IOException ex) {
			}
		}
		
		private byte[] process(byte[] input) {
			byte[] output = new byte[1024];
			output="hello ni".getBytes();
			return output;
		}
	}
}
